package com.fulu.game.bi.service.impl.market;

import cn.hutool.core.date.DateUtil;
import com.fulu.game.bi.entity.po.market.TodayRealtimeStat;
import com.fulu.game.bi.entity.vo.market.TodayRealtimeStatDisplayVO;
import com.fulu.game.bi.mysql.bi.market.TodayRealtimeStatDao;
import com.fulu.game.bi.redis.service.market.TodayRealtimeStatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
public class TodayRealtimeStatServiceImpl implements TodayRealtimeStatService {

    @Autowired
    private TodayRealtimeStatDao todayRealtimeStatDao;

    @Override
    public TodayRealtimeStatDisplayVO today() {
        String statTime = DateUtil.format(new Date(), "yyyy-MM-dd");
        final TodayRealtimeStat day = todayRealtimeStatDao.findDayByStatTime(statTime);

        List<TodayRealtimeStat> hours = todayRealtimeStatDao.findHoursByStatTime(statTime);

        TodayRealtimeStatDisplayVO displayVO = new TodayRealtimeStatDisplayVO();
        displayVO.setDay(day);
        displayVO.setHours(hours);
        return displayVO;
    }

}
